yjx.controller('commentController',['$rootScope','$scope','$timeout','$stateParams','ipCookie','$fetch','modalService','$state',function($rootScope,$scope,$timeout,$stateParams,ipCookie,$fetch,modalService,$state){
    var api = '/product/comment/publish';
    var productId = $stateParams.id;
    $scope.submit = function(){
        $fetch.fetch(
            api,
            {
                params:{
                    comment:$scope.comment,
                    userId:$rootScope.userId?$rootScope.userId:ipCookie('userId'),
                    productId:productId
                },
                type:'post'
            }
        ).then(function(data){
            modalService.mainMsgOk("感谢您的评价")
            history.back();
        }).catch(function(e){
            modalService.mainMsgError(e.msg);
        })
    }
}])